package com.dikang.keer.wms.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * ClassName:MybatisHandler
 * Package:com.dikang.common.config
 * Description: mybatis-plus自动插入时间
 *
 * @date:2021/12/4 18:03
 * @author:caojunjie
 */
@Component
public class MybatisHandler implements MetaObjectHandler {


        //insert操作时要填充的字段
        @Override
        public void insertFill(MetaObject metaObject) {
            this.setFieldValByName("createTime", new Date(),metaObject);
        }

        //update操作时要填充的字段
        @Override
        public void updateFill(MetaObject metaObject) {
            this.setFieldValByName("updateTime",new Date(),metaObject);
        }

}
